<!--
 * @Author: 孙开源 && sunkaiyuan@namenode.cn
 * @Date: 2023-09-20 09:53:46
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @LastEditTime: 2023-09-21 16:03:32
 * @Description: 
 * 
-->
<template>
  <el-dialog  draggable overflow :title="titleMap" v-model="visible" :width="500" destroy-on-close @closed="$emit('closed')">
    <sc-VxeTable ref="xGrid1" :gridEvts="gridEvents" :tablecode="'finance_initialization_material'"
      :gridOps="{ height: 500 }" :url="$API.finance.initialization.browser" :params="urlParams">
      >
    </sc-VxeTable>
    <template #footer>
      <el-button @click="close">取 消</el-button>
    </template>
  </el-dialog>
  <saveMaterial v-if="dialog" ref="saveMaterial" @success="handleSuccess" :subject_id="urlParams.subject_id"
    @closed="dialog = false">
  </saveMaterial>
</template>
<script>
import saveMaterial from "./saveMaterial";
export default {
  emits: ["success", "closed", "update:modeValue"],
  components: { saveMaterial },
  props: {
    urlParams: { type: Object, default: () => { } }
  },
  data() {
    return {
      gridEvents: {
        cellDblclick: ({ row }) => {
          this.edit(row);
        },
        add: () => {
          this.dialog = true;
          this.$nextTick(() => {
            this.$refs.saveMaterial.open("add");
          });
        },

        edit: function ({ button }) {
          this.edit(button.selectRecords[0]);
        },
      },
      unit: "All",
      titleMap: "初始化",
      dialog: false,
      form: {
        id: "",
        data: []
      },
      visible: false,
      isSaveing: false,
    };
  },
  mounted() { },
  methods: {
    handleSuccess() {
      this.$refs.xGrid1.refresh();
    },
    edit(data) {
      this.dialog = true;
      this.$nextTick(() => {
        this.$refs.saveMaterial.setData(data);
        this.$refs.saveMaterial.open("edit");
      });
    },
    close() {
      this.$emit('closed');
    },
    open() {
      this.visible = true;
      return this;
    },
  },
};
</script>

<style></style>
